#include <glib.h>

gint main(gint argc, gchar **argv)
{
    const guchar *key = "XYZ";
    const guchar *data = "ABCD";
    GChecksumType  digest_type = G_CHECKSUM_SHA1;
    const guchar *digest_type_str = "SHA1";

    GHmac *hmac = NULL;
    guint8 *digest = NULL;
    gsize digest_len = 0;
    gint i = 0;

    digest_len = g_checksum_type_get_length(digest_type);

    digest = g_malloc (digest_len);

    hmac = g_hmac_new(digest_type, key, strlen(key));
    g_hmac_update(hmac, data, strlen(data));
    g_hmac_get_digest(hmac, digest, &digest_len);

    g_print("HMAC checksum type: %s, key: %s, str:%s \n", digest_type_str, key, data);
    g_print("digest: \n");
    for(i=0; i<digest_len; i++) {
        g_print("%02x", digest[i]);
    }
    g_print("\n");

    g_free(digest);

    g_hmac_unref(hmac);

    return 0;
}